import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import router from './router'
import App from './App.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from "axios";
import VueAxios from 'vue-axios'


import 'element-plus/dist/index.css'
import './assets/main.css'
import NProgress from 'nprogress'

const app = createApp(App);

app.use(router);
app.use(ElementPlus);
app.use(VueAxios,axios);

axios.interceptors.request.use(config => {
    NProgress.start();
    config.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
    config.headers.Authorization = window.sessionStorage.getItem('token')
    // console.log(window.sessionStorage.getItem('token'))

    return config
})

// axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// app.filter('dateFormat',function (originVal) {
//     const dt = new Date(originVal * 1000)
//     const y = dt.getFullYear()
//     const m = (dt.getMonth() + 1).toString().padStart(2,'0')
//     const d = dt.getDate().toString().padStart(2,'0')
//     const hh = dt.getHours().toString().padStart(2,'0')
//     const mm = dt.getMinutes().toString().padStart(2,'0')
//     const ss  = dt.getSeconds().toString().padStart(2,'0')
//     return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
//
// })

app.mount('#app')



